Introduction
Example of Shiny Apps
Deployment
07 September 2020
Introduction
Example of Shiny Apps
Deployment
library(ggplot2) my_plot <- ggplot(mpg, aes(x = displ, y = hwy, colour = class)) + geom_point() my_plot
library(plotly) my_plot <- ggplot(mpg, aes(x = displ, y = hwy, colour = class)) + geom_point() ggplotly(my_plot)
library(plotly) my_plot <- ggplot(mpg, aes(x = displ, y = hwy, colour = class)) + geom_point() + theme(plot.background = element_rect(fill = "transparent", color = NA)) ggplotly(my_plot)
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("sample_plot")
)
server <- function(input, output) {
output$sample_plot <- renderPlotly({
my_plot <-
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()
ggplotly(my_plot)
})
}
# Run the application
shinyApp(ui = ui, server = server)
library(htmlwidgets) saveWidget(ggplotly(my_plot), "~/Desktop/sample_plotly.html")
...
query <- parseQueryString(session$clientData$url_search)
if ("routes" %in% names(query)) {
selected_stops <- unlist(strsplit(query$stops, ","))
} else{
selected_stops <- c(334, 336) # Use as default
}
...